Fix the startup behaviour when the tdb file exists. We were attempting to
authoremellor@leeni.uk.xensource.com <emellor@leeni.uk.xensource.com>
Wed, 7 Dec 2005 15:44:38 +0000 (15:44 +0000)
committeremellor@leeni.uk.xensource.com <emellor@leeni.uk.xensource.com>
Wed, 7 Dec 2005 15:44:38 +0000 (15:44 +0000)
remove and recreate the /local directory, but the manual_node call only works
if the tdb is empty -- we must use create_node, otherwise the store is
corrupted.

It's not clear to me that the other manual_node calls are safe, but I have only
made this smaller change for the sake of stability.  These other calls should
be reviewed.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
tools/xenstore/xenstored_core.c

index 863250941a7126947617eb2da4aa0a67a7c8f763..a259f3a41f77c0613efbb068ad71b46bf4a4f3e6 100644 (file)
@@ -823,7 +823,7 @@ static struct node *construct_node(struct connection *conn, const char *name)
        node->num_perms = parent->num_perms;
        node->perms = talloc_memdup(node, parent->perms,
                                    node->num_perms * sizeof(node->perms[0]));
-       if (conn->id)
+       if (conn && conn->id)
                node->perms[0].id = conn->id;
 
        /* No children, no data */
@@ -1441,8 +1441,10 @@ static void setup_structure(void)
                   balloon driver will pick up stale entries.  In the case of
                   the balloon driver, this can be fatal.
                */
+               char *tlocal = talloc_strdup(talloc_autofree_context(),
+                                            "/local");
                internal_rm("/local");
-               manual_node("/", "local");
+               create_node(NULL, tlocal, NULL, 0);
        }
        else {
                tdb_ctx = tdb_open(tdbname, 7919, TDB_FLAGS, O_RDWR|O_CREAT,